package com.example.hibernate.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

/**
 * Created by Yasin H on 2018/7/30.
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "order_info")
public class OrderInfo extends AbstractEntity {

    private String sn;  //订单号
    private String remark;

    @ManyToOne(targetEntity = User.class,
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private User user;

    @OneToMany(mappedBy = "orderInfo",
            cascade = CascadeType.ALL,
            fetch = FetchType.LAZY)
    private List<OrderItemInfo> orderItemInfoList;

}
